﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Text;

namespace Bussiness_Objects
{
    /// <summary>
    /// Thong tin table CUONSACH
    /// ---CUONSACH(MaCuonSach,MaSach,TinhTrang)
    /// </summary>
    public class CuonSach : BusinessObjects
    {
        public CuonSach()
        {
            MaCuonSach = MaSach = TinhTrang = int.MaxValue;
        }

        public CuonSach(int _maCuonSach, int _maSach, int _tinhTrang)
        {
            MaCuonSach = _maCuonSach;
            MaSach = _maSach;
            TinhTrang = _tinhTrang;
        }

        public override void SetParameterInsert()
        {
            parms = new object[2];
            SqlParameter _parm = new SqlParameter(parMaSach, MaSach);
            parms[0] = _parm;

            _parm = new SqlParameter(parTinhTrang, TinhTrang);
            parms[1] = _parm;
        }

        public override void SetParameterUpdate()
        {
            parms = new object[3];
            SqlParameter _parm = new SqlParameter(parMaCuonSach, MaCuonSach);
            parms[0] = _parm;

            _parm = new SqlParameter(parMaSach, MaSach);
            parms[1] = _parm;

            _parm = new SqlParameter(parTinhTrang, TinhTrang);
            parms[2] = _parm;
        }

        public void SetParameterUpdateTinhTrang()
        {
            parms = new object[1];
            SqlParameter _parm = new SqlParameter(parMaCuonSach, MaCuonSach);
            parms[0] = _parm;
        }

        public void SetParameterSelectID()
        {
            parms = new object[1];
            SqlParameter _parm = new SqlParameter(parMaSach, MaSach);
            parms[0] = _parm;
        }

        public void SetParameterDelete()
        {
            SetParameterUpdateTinhTrang();
        }

        public int MaCuonSach { get; set; }
        private const string parMaCuonSach = "@MaCuonSach";

        public int MaSach { get; set; }
        private const string parMaSach = "@MaSach";

        public int TinhTrang { get; set; }
        private const string parTinhTrang = "@TinhTrang";
    }
}
